package com.jike.noobmoney.adapter;


import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.jike.noobmoney.R;
import com.jike.noobmoney.contants.ConstantValue;
import com.jike.noobmoney.entity.GoldPromotionEntity;
import com.jike.noobmoney.helper.ImageLoader;


/**
 * Created by kekex on 2018/9/8.
 * top发布者列表adapter
 */

public class TopMouthAdapter extends BaseRecyclerAdapter<GoldPromotionEntity.InviteweekrankBean> {


    private Context context;

    public TopMouthAdapter(Context context) {
        super(R.layout.item_top_mouth);
        this.context = context;
    }

    @Override
    protected void onBindViewHolder(SmartViewHolder holder, GoldPromotionEntity.InviteweekrankBean item, int position) {
        holder.text(R.id.tv_paihang, String.format("%s", position + 1));
        holder.text(R.id.tv_nickname_id, "ID:" + item.getU_id());
        holder.text(R.id.tv_renshu, String.format("邀请活跃用户%s人", item.getInvitenumber()));

        holder.text(R.id.tv_summoney, String.format("%s", item.getSummoney()));
        holder.text(R.id.tv_yujiang, String.format("%s", item.getMoney()));



        LinearLayout ll_head = (LinearLayout) holder.findViewById(R.id.ll_head);
        int layoutPosition = holder.getLayoutPosition();
        if (layoutPosition==0){
            ll_head.setVisibility(View.VISIBLE);
        }else {
            ll_head.setVisibility(View.GONE);
        }


        ImageView photo = (ImageView) holder.findViewById(R.id.iv_user_photo);
        if (item.getAvatar() != null) {
            String url = ConstantValue.IMG_BASEURL + item.getAvatar();
            ImageLoader.displayImageDefaultHead(context, url, photo);
        } else {
            ImageLoader.displayImageDefaultHead(context, R.drawable.task_item_icon, photo);
        }

    }
}
